use tempfirst, clear
global depvar = "theil"
global depvar_d1 = "theil_d1"
global nbnc8iso2 " "
global nbnc8iso2_d1 " "
global clustvar "iso2_d"
*
gen cond = abs((nbnc8iso2isic-L.nbnc8iso2isic)/L.nbnc8iso2isic)
gen byte cond5 = cond==0
*
eststo f_fe: xtreg $depvar lgdpshock3 ltradeshock3 ltradeshock3i  $nbnc8iso2  yd* , robust cluster($clustvar) fe i(firmiso)
eststo f_few: xtreg $depvar lgdpshock3 ltradeshock3 ltradeshock3i  $nbnc8iso2  yd* theilw , robust cluster($clustvar) fe i(firmiso)
*
eststo f_fd: reg $depvar_d1 lgdpshock6 ltradeshock6 ltradeshock6i  $nbnc8iso2_d1  yd* , robust cluster($clustvar)
eststo f_fdw: reg $depvar_d1 lgdpshock6 ltradeshock6 ltradeshock6i  $nbnc8iso2_d1  yd* theilw_d1 , robust cluster($clustvar)
*
eststo f_fefd: xtreg $depvar_d1 lgdpshock6 ltradeshock6 ltradeshock6i  $nbnc8iso2_d1 yd* , robust cluster($clustvar) fe i(firmiso)
eststo f_fefdw: xtreg $depvar_d1 lgdpshock6 ltradeshock6 ltradeshock6i  $nbnc8iso2_d1 yd* theilw_d1 , robust cluster($clustvar) fe i(firmiso)
*
log using $DIRLOG/Replication/tab-firstststagetrue-withglobaltheil.txt, text replace
set linesize 250
esttab f_fe f_fd f_fefd f_few f_fdw f_fefdw, drop(yd*) b(%4.3f) se(%4.3f) r2 starlevels({$^c$} 0.1 {$^b$} 0.05 {$^a$} 0.01)  tex  title() label
esttab f_fe f_fd f_fefd f_few f_fdw f_fefdw, drop(yd*) compress r2 starlevels(c 0.1 b 0.05 a 0.01)  b(%4.3f) se(%4.3f)
eststo clear
log close

